package com.miyu.client1.utils.redis;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.*;
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import redis.clients.jedis.JedisPoolConfig;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.Serializable;
import java.time.Duration;
import java.util.*;

//@Configuration
public class RedisConfig {
    private final static ResourceBundle resourceBundle = ResourceBundle.getBundle("application");

    //服务器地址
    private  final static  String hostName = resourceBundle.getString("spring.redis.host");
    //对应的配置DB
    private  final static  String dbs = resourceBundle.getString("spring.redis.databases");
    //连接端口
    private  final static  int port = Integer.valueOf(resourceBundle.getString("spring.redis.port"));
    //密码
    private  final static  String passWord = resourceBundle.getString("spring.redis.password");


    //连接池最大连接数（使用负值表示没有限制）
    private  final static  int maxActive = Integer.valueOf(resourceBundle.getString("spring.redis.jedis.pool.max-active"));
    //连接池中的最大空闲连接
    private  final static  int maxWait = Integer.valueOf(resourceBundle.getString("spring.redis.jedis.pool.max-wait"));
    //连接池中的最大空闲连接
    private  final static  int maxIdle = Integer.valueOf(resourceBundle.getString("spring.redis.jedis.pool.max-idle"));
    //连接池中的最小空闲连接
    private  final static  int minIdle = Integer.valueOf(resourceBundle.getString("spring.redis.jedis.pool.min-idle"));
    //连接超时时间
    private  final static  int  timeout = Integer.valueOf(resourceBundle.getString("spring.redis.timeout"));
    //是否启用redis
    private  final static  String enable = resourceBundle.getString("spring.redis.enable");
    public static Map<Integer, RedisTemplate<Serializable, Object>> redisTemplateMap = new HashMap<>();
    //初始化db
    private int defaultDb=0;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;



}

